package day10.practice;



/**
 * @Author juzipi
 * @Date 2021/6/24 15:36
 * @Info
 */
public class Bank {

    private Customer[] customers = new Customer[10];//存放客户的数组
    private int numberCustomers;//客户个数

    public Bank(Customer[] customers, int numberCustomers) {
        this.customers = customers;
        this.numberCustomers = numberCustomers;
    }

    public Bank() {

    }

    //添加客户
    public void addCustomer(String firstName, String lastName) {
        Customer customer = new Customer(firstName, lastName);
        //添加一个客户（new Customer）就++一次
        this.customers[numberCustomers++] = customer;
    }

    //获取 Customer
    public Customer getCustomer(int index) {
        if (index >= 0 && index < customers.length){
            return customers[index];
        }
        System.out.println("没找到");
        return null;
    }

    //获取客户的个数
    public int getCustomerNumberssssss() {
        return this.numberCustomers;
    }

    //获取指定客户
    public Account getNumberCustomerById(Integer id) {
        for (Customer customer : customers) {
            Integer accountId = customer.getAccount().getId();
            if (id.equals(accountId)) {
                return customer.getAccount();
            } else {
                System.out.println("没找到此用户");
            }
        }
        return null;
    }

    public Customer[] getCustomers() {
        return customers;
    }

    public void setCustomers(Customer[] customers) {
        this.customers = customers;
    }

    public int getNumberCustomers() {
        return numberCustomers;
    }

    public void setNumberCustomers(int numberCustomers) {
        this.numberCustomers = numberCustomers;
    }
}
